<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>添加联系人界面</title>
    <script src="/js/vue.js"></script>
    <script src="/js/axios-0.18.0.js"></script>
</head>
<body>
    <div id="app">
        <form action="/linkman/add" method="post">
            姓名: <input type="text" name="name" v-model="linkman.name"> <br>
            年龄: <input type="text" name="age" v-model="linkman.age"> <br>
            性别: <input type="radio" name="sex" value="male" v-model="linkman.sex"> 男性
            <input type="radio" name="sex" value="female" v-model="linkman.sex"> 女性 <br>
            地址: <input type="text" name="address" v-model="linkman.address"> <br>
            qq: <input type="text" name="qq" v-model="linkman.qq"> <br>
            email: <input type="text" name="email" v-model="linkman.email"> <br>
            <input type="submit" value="添加" @click="submit">
        </form>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                linkman: {
                    name: "",
                    age: "",
                    sex: "",
                    address: "",
                    qq: "",
                    email: ""
                }
            },
            methods: {
                submit(e) {
                    e.preventDefault();
                    axios.post("/linkman/add", {...this.linkman, age: parseInt(this.linkman.age)}).then(res => {
                        if (res.data.flag) {
                            console.log(this.linkman);
                            window.location.href = "/findAllLinkMan.html";
                        }
                    })
                }
            }
        })
    </script>
</body>
</html>